<?php

class Course_Model extends CI_Model {

    function insertCourse($course) {
        $this->db->insert('COURSE', $course);
    }

    function getCourseList() {
        $this->db->from('COURSE');
        $this->db->order_by('ID');
        $result = $this->db->get();
        $return = array();
        if ($result->num_rows() > 0) {
            foreach ($result->result_array() as $row) {
                $return[$row['ID']] = $row['NAME'];
            }
        }

        return $return;
    }

    function getAllCourses() {
        $this->db->from('COURSE');
        $result = $this->db->get();

        return $result;
    }

    function getVideoTimesByCourseID($courseID) {

        $this->db->from('COURSE');
        $this->db->where('ID', $courseID);
        $results = $this->db->get()->row();

        return $results;
    }

    function getAllCourse($per_page, $offset) {
        $this->db->select('ID, CODE, NAME, HOURS, PRICE, DETAIL');
        $this->db->from('COURSE');
        $this->db->limit($per_page, $offset);
        $query = $this->db->get();

        return $query;
    }

    function getCourseByID($courseID) {
        $this->db->from('COURSE');
        $this->db->where('ID', $courseID);
        $query = $this->db->get();

        return $query;
    }

    function getAllCourseNotRegis($courseIDList){
        $this->db->from('COURSE');
        $this->db->where_not_in('ID', $courseIDList);
        $query = $this->db->get()->result();

        return $query;
    }
}

?>
